In [10]:
include("utils.jl")
using DiffusionTutorialUtilities
utils = DiffusionTutorialUtilities
A,xy = utils.load_graph_and_coords("four_clusters")


WARNING: replacing module DiffusionTutorialUtilities
Out[10]:
(
27x27 sparse matrix with 102 Float64 entries:
	[2 ,  1]  =  1.0
	[3 ,  1]  =  1.0
	[5 ,  1]  =  1.0
	[6 ,  1]  =  1.0
	[1 ,  2]  =  1.0
	[4 ,  2]  =  1.0
	[1 ,  3]  =  1.0
	[6 ,  3]  =  1.0
	[7 ,  3]  =  1.0
	[2 ,  4]  =  1.0
	⋮
	[14, 25]  =  1.0
	[23, 25]  =  1.0
	[24, 25]  =  1.0
	[26, 25]  =  1.0
	[27, 25]  =  1.0
	[23, 26]  =  1.0
	[24, 26]  =  1.0
	[25, 26]  =  1.0
	[23, 27]  =  1.0
	[24, 27]  =  1.0
	[25, 27]  =  1.0,

27x2 Array{Float64,2}:
 112.0   72.0
 105.0  107.0
 145.0  116.0
 154.0   79.0
 182.0  114.0
 119.0  146.0
 158.0  153.0
 197.0   79.0
 202.0  149.0
 305.0  107.0
 303.0  139.0
 362.0  123.0
 349.0   62.0
   ⋮         
 124.0  235.0
 165.0  238.0
 204.0  235.0
 183.0  272.0
 153.0  203.0
 130.0  274.0
 220.0  276.0
 311.0  258.0
 306.0  217.0
 336.0  194.0
 352.0  240.0
 275.0  195.0)
Results from Matlab
gsqexpmedseed: psivec[14] = 1.333333333333333259e+00 
gsqexpmedseed: psivec[13] = 1.476190476190476275e+00 
gsqexpmedseed: psivec[12] = 1.567765567765567747e+00 
gsqexpmedseed: psivec[11] = 1.653235653235653135e+00 
gsqexpmedseed: psivec[10] = 1.751470751470751264e+00 
gsqexpmedseed: psivec[ 9] = 1.875735375735375632e+00 
gsqexpmedseed: psivec[ 8] = 2.042075208741874981e+00 
gsqexpmedseed: psivec[ 7] = 2.276297005463671752e+00 
gsqexpmedseed: psivec[ 6] = 2.625926432474050998e+00 
gsqexpmedseed: psivec[ 5] = 3.188272027061709313e+00 
gsqexpmedseed: psivec[ 4] = 4.188272027061708869e+00 
gsqexpmedseed: psivec[ 3] = 6.235340033827135642e+00 
gsqexpmedseed: psivec[ 2] = 1.139223338971189214e+01 
gsqexpmedseed: psivec[ 1] = 2.948058347427972947e+01 
gsqexpmedseed: psivec[ 0] = 1.484029173713986438e+02 

We get this seeds right

gsqexpmedseed: pushcoeff[ 1] = 3.356178691466748062e-05 
gsqexpmedseed: pushcoeff[ 2] = 8.685049075428625880e-05 
gsqexpmedseed: pushcoeff[ 3] = 1.586795676444538244e-04 
gsqexpmedseed: pushcoeff[ 4] = 2.362361026912510303e-04 
gsqexpmedseed: pushcoeff[ 5] = 3.103314435800159877e-04 
gsqexpmedseed: pushcoeff[ 6] = 3.767893298334516077e-04 
gsqexpmedseed: pushcoeff[ 7] = 4.346625498821070181e-04 
gsqexpmedseed: pushcoeff[ 8] = 4.845174440433207860e-04 
gsqexpmedseed: pushcoeff[ 9] = 5.274843527946711285e-04 
gsqexpmedseed: pushcoeff[10] = 5.649086973636321517e-04 
gsqexpmedseed: pushcoeff[11] = 5.984755160266384171e-04 
gsqexpmedseed: pushcoeff[12] = 6.311026859034799853e-04 
gsqexpmedseed: pushcoeff[13] = 6.702529765922815227e-04 
gsqexpmedseed: pushcoeff[14] = 7.420657955128831919e-04 
gsqexpmedseed: pushcoeff[15] = 9.894210606838441113e-04 

We seem to get these right too

In [12]:
size(A)


Out[12]:
(27,27)

In [14]:
# what is wrong

# that was the output from the Matlab code
include("diffusions.jl")
using DiffusionAlgorithms
hkvec = DiffusionAlgorithms.hk_relax_solution(A,5.,1,1.e-4)
@printf "hkvec[1] = %.18e\n" hkvec[1]
@printf " true[1] = %.18e\n" 19.359526487166217
@printf "hkvec[1] = %.18e\n" hkvec[2]
@printf " true[1] = %.18e\n" 9.408867012443888


WARNING: replacing module DiffusionAlgorithms
hkvec[1] = 1.935901229830458803e+01
 true[1] = 1.935952648716621738e+01
hkvec[1] = 9.405980777381179436e+00
 true[1] = 9.408867012443888456e+00

In [23]:
A,xy = utils.load_graph_and_coords("newman-netsci")
include("diffusions.jl")
using DiffusionAlgorithms
pprvec = DiffusionAlgorithms.ppr_push_solution(A,0.99,1,1.e-7)
@printf("True = 0.026124014066724\n")
@printf("x[0] = %.15f\n", pprvec[1]) # Matlab gave 0.026124014066724


WARNING: replacing module DiffusionAlgorithms
True = 0.026124014066724
x[0] = 0.026124014066724

In [29]:
#Test sweep cut
A,xy = utils.load_graph_and_coords("four_clusters")
include("diffusions.jl")
using DiffusionAlgorithms
pprvec = DiffusionAlgorithms.ppr_push_solution(A,0.99,1,1.e-7)
DiffusionAlgorithms.degree_normalized_sweep_cut!(A,pprvec)


WARNING: replacing module DiffusionAlgorithms
Out[29]:
(Set([7,4,9,2,3,5,8,6,1]),0.058823529411764705,(2.0,34.0))

In [36]:
#Test sweep cut
A,xy = utils.load_graph_and_coords("four_clusters")
include("diffusions.jl")
using DiffusionAlgorithms
@show bestset,bestcond = DiffusionAlgorithms.ppr_grow(A,1)
@show bestset,bestcond = DiffusionAlgorithms.hk_grow(A,1)


WARNING: replacing module DiffusionAlgorithms
(bestset,bestcond) = DiffusionAlgorithms.ppr_grow(A,1) = (Set([7,4,9,2,3,5,8,6,1]),0.058823529411764705,(2.0,34.0))
Out[36]:
(Set([7,4,9,2,3,8,5,6,1]),0.058823529411764705,(2.0,34.0))
(bestset,bestcond) = DiffusionAlgorithms.hk_grow(A,1) = (Set([7,4,9,2,3,8,5,6,1]),0.058823529411764705,(2.0,34.0))